/**************************提示：只允许修改开发区域，其他区域会被覆盖！********************************/
mod.definePage("extend/fi/gl/js/voucherListPage001",function(waf){
    //@beginUseModule
    var voucherListPage = mod.useSync("fi/gl/js/voucherListPage");
    //@endUseModule
    var _public = {},_private = {},me=_self;
    //@beginPublic
    waf.extend(_public,{
        //控件事件描述:
        impVoucher:function(event,value){
             return _private.impVoucher(event,value);
        }
	    ,
        //页面函数描述:弹出上传凭证提示
        showConfirm:function(data){
             return _private.showConfirm(data);
        }
    });
    //@endPublic
    //@beginTemplateFunctions

    //@endTemplateFunctions

    /**************************开发区域开始**********************************************/
    //@beginPrivate
    waf.extend(_private,{
    	impVoucher:function(event,value){
          waf.msgBox.showConfirm({
              title:"信息提示",
              summaryMsg:"您确认要执行此操作吗？",
              buttonType:"yes-no",
              buttonCallBack:[function(){
                    var ids=waf("#queryGrid").wafGrid("getSelectedRows");
                    if(ids.length==0){
                     		waf.msgBox.showWarning("请选择一行数据");
                    }else{
                            var voucherids={}; 
                            for(var i=0;i<ids.length;i++){
                                var voucherid=waf("#queryGrid").wafGrid("getRowRealData",ids[i]).voucherid;
                                var number=waf("#queryGrid").wafGrid("getRowRealData",ids[i]).number;
                                voucherids[voucherid]=number;
                            }
                     	   waf.block.show({
                              text:"正在上传申康凭证中，请稍等..."
                            });
                            var option=_self.getOptionFromArguments(arguments);
                            option.action="impVoucherAction";
                            option.data={"ids":JSON.stringify(voucherids)};
                            option.success=function(data){
                                 _private.showConfirm(data);
                            }
                          waf.doPost(option);
                    }
              },function(){}]
          });
        }
    	,
		showConfirm:function(data){
          var rootDiv=waf('<div class="waf-messageBox-content waf-widget-content" style="back"></div>');
           var tableDiv='<table style="border:1px solid;margin: 10px;border-collapse: collapse;"><thead><tr><th style="border:1px solid">凭证号</th><th style="border:1px solid">处理结果</th></tr></thead><tbody>';
          for(var i=0;i<data.length;i++){
      			var json=data[i];
      			var contDiv = "<tr>" + 
                                          "<td style='border:1px solid'>" +json.number+ "</td>" +
                                          "<td style='border:1px solid'>" +json.msg+ "</td>" +
                                       "</tr>";
     		 tableDiv+=contDiv;
           }
          tableDiv+="</tbody></table>";
           rootDiv.append(tableDiv);
          waf.block.hide();
          waf.msgBox.showConfirm({
              target:rootDiv,
          });
        }
    });//@endPrivate
    /**************************开发区域结束**********************************************/
    return _public;
});
